import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"; 

Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [
    createPersistedState({ storage: window.sessionStorage }) //配置为sessionStorage，如果不传入对象就是默认
  ],
  state: {
    userdata: null,         // 本人的信息
    newmessage:null,      // 本人在线时，有人发送的新消息
    newuser:null,       // 新登陆的好友信息
    olduser:null,       // 退出登陆的好友信息
    index:0,        // 主路由的index值
  },
  mutations: {
    setindex(state, data){
      state.index=data
    },
    removeindex(state, data){
      state.index=null
    },
    setnewmessage(state, data){
      state.newmessage=data
    },
    removenewmessage(state, data){
      state.newmessage=null
    },


    setuserdata(state, data) {
      state.userdata = data
    },
    removeuserdata(state){
      state.userdata = null
    },
    setnewuserdata(state, data) {
      state.newuser = data
    },
    removenewuserdata(state){
      state.newuser = null
    },
    setolduserdata(state, data) {
      state.olduser = data
    },
    removeolduserdata(state){
      state.olduser = null
    },
    
  },
  actions: {
  },
  modules: {
  }
})
